/**
 * Created by Blink on 2017/8/21.
 * define custom prop types
 */
import map from '../icon.maps';
import PropTypes from 'prop-types';
import colors from '../theme/color';

export default  {
    icon: (props, propName, componentName) => {
        const name = props[propName];

        if (name) {
            if (typeof name !== 'string') {
                return new Error('icon must be a string');
            } else if (!map.hasOwnProperty(name)) {
                return new Error('invalid icon name "' + name + '". check icon.maps.js');
            }
        }
    },

    color: (props, propName) => {
        const name = props[propName];

        if (name) {
            if (typeof name !== 'string') {
                return new Error('color must be a string.');
            }
        }
    },

    theme: (props, propName) => {
        const name = props[propName];

        if (!colors.has(name)) {
            return new Error('unknow theme "' + name + '", check theme/color.js');
        }
    }
};
